package com.jrx.anytxn.accounting.service.impl;

import com.jrx.anytxn.accounting.entity.GaVoucherInfo;
import com.jrx.anytxn.accounting.mapper.ext.ExtGaProductSummaryTransitionMapper;
import com.jrx.anytxn.accounting.service.IInvestorAccountingFileService;
import com.jrx.anytxn.common.uitl.DateUtils;
import com.jrx.anytxn.investor.constant.TransBizConstant;
import com.jrx.anytxn.param.dto.investor.FileBean;
import com.jrx.anytxn.param.entity.GaInvestorSubjectConfig;
import com.jrx.anytxn.param.entity.PrOrganizationTable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @program: anytxn-cf-transaction
 * @description:
 * @author: xiaoyu.jing
 * @date: 2020-06-15 17:27
 **/
@Service
public class InvestorAccountingFileServiceImpl implements IInvestorAccountingFileService {


    @Override
    public FileBean createAccountingFileMessage(GaVoucherInfo info) {
        FileBean fileBean = new FileBean();
        StringBuilder sb = new StringBuilder();
        String businessDate = info.getBusinessDate() == null ? "" : DateUtils.formatDate(info.getBusinessDate(), DateUtils.DATE_PATTERN_ANOTHER);
        sb.append(businessDate).append(TransBizConstant.separator);
        sb.append(info.getFlowno() == null ? "" : info.getFlowno()).append(TransBizConstant.separator);
        sb.append(info.getSeq() == null ? "" : info.getSeq()).append(TransBizConstant.separator);
        sb.append(info.getSubjectId() == null ? "" : info.getSubjectId()).append(TransBizConstant.separator);
        sb.append(info.getAmount() == null ? "0.00" : info.getAmount().toPlainString()).append(TransBizConstant.separator);
        sb.append(info.getCustomerId() == null ? "" : info.getCustomerId()).append(TransBizConstant.separator);
        sb.append(info.getLoanId() == null ? "" : info.getLoanId()).append(TransBizConstant.separator);
        sb.append(info.getProductId() == null ? "" : info.getProductId()).append(TransBizConstant.separator);
        sb.append(info.getChannel() == null ? "" : info.getChannel()).append(TransBizConstant.separator);
        sb.append(info.getTxnCode() == null ? "" : info.getTxnCode()).append(TransBizConstant.separator);
        sb.append(info.getDescription() == null ? "" : info.getDescription()).append(TransBizConstant.separator);
        sb.append( "\r\n");
        fileBean.setInvestorId(info.getInvestorId());
        fileBean.setFileString(sb.toString());
        return fileBean;
    }
}
